import 'package:eh_mobile/common/values/svg_image.dart';
import 'package:eh_mobile/pages/control/light_control/widgets/select_mode_overlay.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class LightControlController extends GetxController {
  LightControlController();

  // 默认选中的
  final currectIndex = 0.obs;
  // 灯光亮度
  final brightnessValue = 0.5.obs;
  // 色温
  final colorTempValue = 0.6.obs;

  final lightOpen = true.obs;

  // 是否显示颜色调整色盘
  final showColourDisk = false.obs;

  final PageController pageController = PageController();

  // 灯光控制类型图标
  final List<String> lightControlTypeIcons = [
    SVGImage.icColorSelSvg,
    SVGImage.icColorTemperatureSvg,
    SVGImage.icModeUnselSvg,
    SVGImage.icFxUnselSvg,
    SVGImage.icPowerOnSvg
  ];

  // 当前设置的灯光颜色
  final lightColor = const Color.fromRGBO(255, 248, 204, 1).obs;

  // 灯光控制灯光颜色
  final lightControlColors = <Color>[
    const Color.fromRGBO(255, 248, 204, 1),
    const Color.fromRGBO(23, 175, 255, 1),
    const Color.fromRGBO(255, 75, 174, 1),
    const Color.fromRGBO(255, 255, 255, 1),
    const Color.fromRGBO(69, 69, 69, 0.9)
  ].obs;

  // 灯光控制灯光颜色
  final lightBrightnessColors = <Color>[
    const Color.fromRGBO(255, 255, 255, 0.6),
    const Color.fromRGBO(255, 255, 255, 0.3),
    const Color.fromRGBO(255, 255, 255, 0.8),
    const Color.fromRGBO(255, 255, 255, 0.5),
    const Color.fromRGBO(69, 69, 69, 0.9)
  ].obs;

  final _modelList = <String>[
    '正常',
    '阅读',
    '日间',
    '夜灯',
    '电脑',
    '电视',
    '会客',
    '娱乐',
    '唤醒',
    '黄昏',
    '睡眠',
    '温暖',
    '月光'
  ];
  // 当前灯光控制选择下标
  final lightControlTypeIndex = 0.obs;

  _initData() {
    // update(["light_control"]);
  }

// 选择模式item点击事件
  void lightModelItemClick(int index) {
    if (index < 2) {
      pageController.animateToPage(
        index,
        duration: const Duration(milliseconds: 300),
        curve: Curves.easeOutCubic,
      );
      lightControlTypeIndex.value = index;
    } else if (index == 2) {
      SelectModeOverlay.show(
        Get.context!,
        _modelList,
        selectModeOverlayCallBack: (value,name) {},
      );
    } else if (index == 3) {
      SelectModeOverlay.show(
        Get.context!,
        _modelList,
        selectModeOverlayCallBack: (value,name) {
          print(value);
        },
      );
    } else if (index == 4) {
      lightOpen.value = !lightOpen.value;
    }
  }

  /// 在 widget 内存中分配后立即调用。
  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    _initData();
  }

  /// 在 [onDelete] 方法之前调用。
  @override
  void onClose() {
    super.onClose();
  }

  /// dispose 释放内存
  @override
  void dispose() {
    super.dispose();
  }
}
